Exchange Maven Facade icon

Exchange Maven Facade

(0 reviews)

Getting Started

The Maven Facade provides an API that interacts with Maven clients. This API supports deploying and consuming assets using Maven.

Configuring Maven

Create the ~/.m2/settings.xml file to hold the settings that the mvn client uses when you run it. You need to configure your credentials for the Exchange Maven Facade as follows:

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
  http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <servers>
    <server>
      <id>Repository</id>
      <username>USERNAME</username>
      <password>PASSWORD</password>
    </server>
  </servers>
</settings>

The <id> value is arbitrary, but must have the same value in your pom.xml and settings.xml files. The <server> ... <id> value in the settings.xml file is the same value as the <repository> ... <id> value in the pom.xml file.

Using an Access Token

Exchange Maven Facade supports using a Core Services access token instead of a username and password. To achieve this, put the special user ~~~Token~~~ in your settings.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
  http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <servers>
    <server>
      <id>Repository</id>
      <username>~~~Token~~~</username>
      <password>ACCESS_TOKEN</password>
    </server>
  </servers>
</settings>

Publishing with Maven

To publish an asset using Maven, add the Exchange Maven Facade as a repository in the distribution management section of your project's POM file. Example:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
 http://maven.apache.org/xsd/maven-4.0.0.xsd">

  <name>Asset Name</name>
  <description>Asset Description</description>

[...]
  <distributionManagement>
    <repository>
      <id>Repository</id>
      <name>Corporate Repository</name>
      <url>https://maven.anypoint.mulesoft.com/api/v2/organizations/ORGANIZATION_ID/maven</url>
      <layout>default</layout>
    </repository>
  </distributionManagement>
[...]
</project>

The <id> value you use here must match the one you used in settings.xml. With that, you can now publish your releases to Exchange using Maven deploy phase, for example, using the CLI:

mvn deploy
Mule 4.x

Publication of Mule 4.x projects is fully supported in Exchange Maven Facade without use of the <properties> tag.

Mule 3.x

Publication of Mule 3.x projects is fully supported by Exchange Maven Facade. However, to publish some types of projects, you need to add an extra <properties> tag in the POM file.

These cases are:

  • Templates:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
 http://maven.apache.org/xsd/maven-4.0.0.xsd">
[...]
  <properties>
    <type>template</type>
  </properties>
[...]
</project>
  • Examples:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
 http://maven.apache.org/xsd/maven-4.0.0.xsd">
[...]
  <properties>
    <type>example</type>
  </properties>
[...]
</project>
  • Mule Applications:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
 http://maven.apache.org/xsd/maven-4.0.0.xsd">
[...]
  <properties>
    <type>app</type>
  </properties>
[...]
</project>
  • Connectors built with DevKit:

Because these connectors use a special packaging (<packaging>mule-module</packaging>) that the Exchange Maven Facade uses to infer the type, no extra properties are required.

Consuming with Maven

To consume an asset published in Exchange using Maven, add the Exchange Maven Facade as a repository in the repositories section and the groupId, artifactId (assetId), and version of the asset you want to depend on in the dependencies section of your POM file. Example:

<project xmlns="http://maven.apache.org/POM/4.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
  http://maven.apache.org/xsd/maven-4.0.0.xsd">
[...]

  <dependencies>
    <dependency>
      <groupId>org.mule.modules</groupId>
      <artifactId>mule-module-sfdc</artifactId>
      <version>8.0.0-SNAPSHOT</version>
    </dependency>
  </dependencies>

[...]

  <repositories>
    <repository>
      <id>Repository</id>
      <name>Corporate Repository</name>
      <url>https://maven.anypoint.mulesoft.com/api/v2/organizations/ORGANIZATION_ID/maven</url>
      <layout>default</layout>
    </repository>
  </repositories>
[...]
</project>

Reviews